package example.mq;

import example.constant.CommentConstant;
import example.entity.UserEntity;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

/**
 * @Description: 邮件消费者
 * @Author: mingtian
 * @CreateDate: 2021/1/17 11:20
 * @Version: 1.0
 */
@Component
@RabbitListener(queues = CommentConstant.FANOUT_EMAIL_QUEUE)
public class FanoutEmailConsumer {

    /**
     * 打印日志
     */
    private Logger logger = LoggerFactory.getLogger(getClass());

    /**
     * 接受字符串方式方法
     *
     * @param msg
     */
    @RabbitHandler
    public void process(String msg) {
        logger.info("邮件消费者接收消息:{}", msg);
    }

    /**
     * 接收实体对象方式方法
     *
     * @param userEntity
     */
    @RabbitHandler
    public void process(UserEntity userEntity) {
        logger.info("邮件消费者接收消息:{}", userEntity);
    }
}
